package river_city_ransom.implementations;

import exceptions.ComposantError;
import river_city_ransom.services.Dimensions;
import river_city_ransom.services.Equipable;
import river_city_ransom.services.Position;
import tools.Toolbox;


public abstract class Equipable_I implements Equipable {
	protected Dimensions dimensions;
	protected boolean estEquipable;
	protected boolean estPorte;
	protected int estJete;
	protected Position position;
	
	@Override
	public boolean equals(Object o) {
		if(!(o instanceof Equipable)) {
			return false;
		}
		if(!Toolbox.equals(dimensions(), ((Equipable) o).dimensions())) {
			return false;
		}
		if(estEquipable() != ((Equipable) o).estEquipable()) {
			return false;
		}
		if(estPorte() != ((Equipable) o).estPorte()) {
			return false;
		}
		if(!Toolbox.equals(position(), ((Equipable) o).position())) {
			return false;
		}
		
		return true;
	}

	/** _________________________________________________________ OBSERVATORS */
	@Override
	public Dimensions dimensions() {
		return dimensions;
	}

	@Override
	public boolean estEquipable() {
		return estEquipable;
	}

	@Override
	public boolean estPorte() {
		return estPorte;
	}

	@Override
	public int estJete() {
		return estJete;
	}

	@Override
	public Position position() {
		return position;
	}
	
	/** ___________________________________________________________ OPERATORS */
	@Override
	public void etreRamasse() throws ComposantError {
		estPorte = true;
		estJete = 0;
	}
	
	@Override
	public void etreJete(boolean d) throws ComposantError {
		estPorte = false;
		estJete = d ? 1 : -1;
	}
	
	
}
